/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package BLO;

import DAO.TeacherDAO;
import DTO.TeacherDTO;
import Util.ConnectionUtil;
import java.sql.Connection;
import java.util.ArrayList;

/**
 *
 * @author Arturia
 */
public class TeacherBLO {
    private Connection con;

    public ArrayList<TeacherDTO> getAllTeachers() {
        ArrayList<TeacherDTO> list = new ArrayList<TeacherDTO>();
        try {
            con = ConnectionUtil.getConnection();
            list = TeacherDAO.LoadDatabase(con, null);

        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }

    public boolean insertTeacher(TeacherDTO person){
        con = ConnectionUtil.getConnection();
        if (TeacherDAO.insert(con, person) > 0) {
            return true;
        }
        return false;
    }

    public boolean updateTeacher(TeacherDTO person){
        con = ConnectionUtil.getConnection();
        if (TeacherDAO.update(con, person) > 0) {
            return true;
        }
        return false;
    }

    public boolean deleteTeacher(String deleteTeacher){
        con = ConnectionUtil.getConnection();
        if(TeacherDAO.delete(con, deleteTeacher) > 0){
            return true;
        }
        return false;
    }
}
